<div class="layui-colla-item">
    <h2 class="layui-colla-title">table
        <div>
        </div>
    </h2>
    <div class="layui-colla-content layui-show">
        <div class="layui-row">
            <div class="layui-card">
            <div class="layui-card-header layui-bg-gray layui-bottom">
                <label>关联类型：</label>
                <div class="layui-inline ">
                    <div class="layui-input-inline " style="width: 100px;">
                        <div class="layui-form">
                        <select name="relevanceType[queryType]" lay-filter="queryType" class="selectDate" aria-invalid="false">
                            <foreach name="g_meth" item="vo" key="k">
                                <option value="{$k}" <?php if(isset($relevanceType['queryType']) && $relevanceType['queryType'] == $k){echo 'selected';}?> >{$k}</option>
                            </foreach>
                        </select>
                        </div>
                    </div>
                </div>
                <!-- <php>
                    $c = array_keys($g_meth)[0];
                </php>
                <div class="layui-inline ">
                    <div class="layui-input-inline " style="width: 100px;">
                        <select name="relevanceType[way]" lay-filter="" id="way">
                            <foreach name="g_meth[$c]" item="vo" key="k">
                                <option value="{$vo}" <?php if(isset($relevanceType['way']) && $relevanceType['way'] == $vo){echo 'selected';}?>>{$vo}</option>
                            </foreach>
                        </select>
                    </div>
                </div> -->
            </div>
            <div class="layui-card-body layui-nopadding table-list">
                <table  class="layui-table layui-nomargin">
                    <thead> 
                        <tr>
                            <th>字段名</th>
                            <th>关联规则</th>
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
;!function(){
    //显示数据
    $.ajax({
        url:"{:cmf_plugin_url('ModuleConfig://relevance_config/getRelevance')}",
        data:$('#search-form').serialize(),
        success:function(data){
            var relevance = data.data.relevance;
            if (data.code == 1) {
                $.each(data.data.field,function(k,v){
                    var tables = $('.table-list tbody');
                    var html = $(
                            '<tr>'+
                                '<td width="200"><input type="text" name="form['+k+'][field]" class="layui-input" readonly="readonly"  value="'+v+'"></td>'+
                                '<td>'+
                                    '<textarea placeholder="请输入内容" name="form['+k+'][relev]" class="layui-textarea">'+relevance[v]+'</textarea>'+
                                '</td>'+
                            '</tr>'
                        );
                    html.appendTo(tables);
                    form.render();
                }) 
            }
        }
    });
  var layer = layui.layer
    ,form = layui.form;
    var common_n = 'fsadfdsaf';
    var i = 100;
    //添加一行
    $('.add-table-line').on('click',function(){
        // $('.table-bordered tbody tr').each(function(){
        //     common_n = $(this).closest('tr').find('input[name="title"]').val();
        // })
        if (common_n.length > 0){
            var tables = $('.table-list tbody');
            var html = $(
                '<tr>'+
                '<td><input type="text" name="form[table]['+i+'][title]" class="layui-input"></td>'+
                '<td><input type="text" name="form[table]['+i+'][fields]" class="layui-input"></td>'+
                '<td><input type="text" name="form[table]['+i+'][field_alias]" class="layui-input"></td>'+
                '<td><input type="text" name="form[table]['+i+'][ctrl_name]" class="layui-input"></td>'+
                '<td>'+
                    '<select name="form[table]['+i+'][ctrl_type]">'+
                        '<foreach name="ctrl_type" item="ty" key="k">'+
                            '<option value="{$k}">{$ty}</option>'+
                        '</foreach>'+
                    '</select>'+
                '</td>'+
                '<td>'+
                    '<input type="checkbox" name="form[table]['+i+'][is_show]"  lay-skin="switch"  lay-text="ON|OFF" value="1">'+
                '</td>'+
                '<td>'+
                    '<select name="form[table]['+i+'][show_type]">'+
                        '<option value="1">原样输出</option>'+
                        '<option value="2">固定字段</option>'+
                    '</select>'+
                '</td>'+
                '<td>'+
                    '<textarea placeholder="请输入内容" name="form[table]['+i+'][option]" class="layui-textarea"></textarea>'+
                '</td>'+
                '<td>'+
                    '<select name="form[table]['+i+'][rule]">'+
                        '<option value="date">date</option>'+
                        '<option value="mage">mage</option>'+
                    '</select>'+
                '</td>'+
                '<td>'+
                    '<select name="form[table]['+i+'][table_name]">'+
                        '<option value="cmf_member">cmf_member</option>'+
                        '<option value="cmf_member_detail">cmf_member_detail</option>'+
                    '</select>'+
                '</td>'+
                '<td>'+
                    '<input type="text" name="form[table]['+i+'][field_one]" class="layui-input">'+
                '</td>'+
                '<td>'+
                    '<select name="form[table]['+i+'][cover_table]">'+
                        '<option value="cmf_member">cmf_member</option>'+
                        '<option value="cmf_member_detail">cmf_member_detail</option>'+
                    '</select>'+
                '</td>'+
                '<td>'+
                    '<input type="text" name="form[table]['+i+'][field_two]" class="layui-input">'+
                '</td>'+
                '<td>'+
                    '<select name="form[table]['+i+'][relevance]">'+
                        '<option value="cmf_member">join</option>'+
                    '</select>'+
                '</td>'+
                '<td>'+
                    '<input type="text" name="form[table]['+i+'][condtion]" class="layui-input">'+
                '</td>'+
                '<td>'+
                    '<span class="layui-btn layui-btn-xs" onclick="deletetr(this)">删除</span>'+
                '</td>'+
            '</tr>'
            );
            html.appendTo(tables);
            i+=1;
            form.render();
        } else {
            layer.msg('请填写内容！',{icon:2,time:1000});
        }
    })
}();
function deletetr(t){
    $(t).parent().parent().remove();
}
</script>
